3.9.72 \(\int (a+b \sec (c+d x))^2 (A+B \sec (c+d x)+C \sec ^2(c+d x)) \, dx\) [872]

Optimal. Leaf size=134 \[ a^2 A x+\frac {\left (2 a^2 B+b^2 B+2 a b (2 A+C)\right ) \tanh ^{-1}(\sin (c+d x))}{2 d}+\frac {\left (3 A b^2+6 a b B+2 a^2 C+2 b^2 C\right ) \tan (c+d x)}{3 d}+\frac {b (3 b B+2 a C) \sec (c+d x) \tan (c+d x)}{6 d}+\frac {C (a+b \sec (c+d x))^2 \tan (c+d x)}{3 d} \]

[Out]

a^2*A*x+1/2*(2*a^2*B+b^2*B+2*a*b*(2*A+C))*arctanh(sin(d*x+c))/d+1/3*(3*A*b^2+6*B*a*b+2*C*a^2+2*C*b^2)*tan(d*x+
c)/d+1/6*b*(3*B*b+2*C*a)*sec(d*x+c)*tan(d*x+c)/d+1/3*C*(a+b*sec(d*x+c))^2*tan(d*x+c)/d

________________________________________________________________________________________

Rubi [A]
time = 0.13, antiderivative size = 134, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 5, integrand size = 33, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.152, Rules used = {4141, 4133, 3855, 3852, 8} \begin {gather*} \frac {\tan (c+d x) \left (2 a^2 C+6 a b B+3 A b^2+2 b^2 C\right )}{3 d}+\frac {\left (2 a^2 B+2 a b (2 A+C)+b^2 B\right ) \tanh ^{-1}(\sin (c+d x))}{2 d}+a^2 A x+\frac {b (2 a C+3 b B) \tan (c+d x) \sec (c+d x)}{6 d}+\frac {C \tan (c+d x) (a+b \sec (c+d x))^2}{3 d} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[(a + b*Sec[c + d*x])^2*(A + B*Sec[c + d*x] + C*Sec[c + d*x]^2),x]

[Out]

a^2*A*x + ((2*a^2*B + b^2*B + 2*a*b*(2*A + C))*ArcTanh[Sin[c + d*x]])/(2*d) + ((3*A*b^2 + 6*a*b*B + 2*a^2*C +
2*b^2*C)*Tan[c + d*x])/(3*d) + (b*(3*b*B + 2*a*C)*Sec[c + d*x]*Tan[c + d*x])/(6*d) + (C*(a + b*Sec[c + d*x])^2
*Tan[c + d*x])/(3*d)

Rule 8

Int[a_, x_Symbol] :> Simp[a*x, x] /; FreeQ[a, x]

Rule 3852

Int[csc[(c_.) + (d_.)*(x_)]^(n_), x_Symbol] :> Dist[-d^(-1), Subst[Int[ExpandIntegrand[(1 + x^2)^(n/2 - 1), x]
, x], x, Cot[c + d*x]], x] /; FreeQ[{c, d}, x] && IGtQ[n/2, 0]

Rule 3855

Int[csc[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-ArcTanh[Cos[c + d*x]]/d, x] /; FreeQ[{c, d}, x]

Rule 4133

Int[((A_.) + csc[(e_.) + (f_.)*(x_)]*(B_.) + csc[(e_.) + (f_.)*(x_)]^2*(C_.))*(csc[(e_.) + (f_.)*(x_)]*(b_.) +
 (a_)), x_Symbol] :> Simp[(-b)*C*Csc[e + f*x]*(Cot[e + f*x]/(2*f)), x] + Dist[1/2, Int[Simp[2*A*a + (2*B*a + b
*(2*A + C))*Csc[e + f*x] + 2*(a*C + B*b)*Csc[e + f*x]^2, x], x], x] /; FreeQ[{a, b, e, f, A, B, C}, x]

Rule 4141

Int[((A_.) + csc[(e_.) + (f_.)*(x_)]*(B_.) + csc[(e_.) + (f_.)*(x_)]^2*(C_.))*(csc[(e_.) + (f_.)*(x_)]*(b_.) +
 (a_))^(m_.), x_Symbol] :> Simp[(-C)*Cot[e + f*x]*((a + b*Csc[e + f*x])^m/(f*(m + 1))), x] + Dist[1/(m + 1), I
nt[(a + b*Csc[e + f*x])^(m - 1)*Simp[a*A*(m + 1) + ((A*b + a*B)*(m + 1) + b*C*m)*Csc[e + f*x] + (b*B*(m + 1) +
 a*C*m)*Csc[e + f*x]^2, x], x], x] /; FreeQ[{a, b, e, f, A, B, C}, x] && NeQ[a^2 - b^2, 0] && IGtQ[2*m, 0]

Rubi steps

\begin {align*} \int (a+b \sec (c+d x))^2 \left (A+B \sec (c+d x)+C \sec ^2(c+d x)\right ) \, dx &=\frac {C (a+b \sec (c+d x))^2 \tan (c+d x)}{3 d}+\frac {1}{3} \int (a+b \sec (c+d x)) \left (3 a A+(3 A b+3 a B+2 b C) \sec (c+d x)+(3 b B+2 a C) \sec ^2(c+d x)\right ) \, dx\\ &=\frac {b (3 b B+2 a C) \sec (c+d x) \tan (c+d x)}{6 d}+\frac {C (a+b \sec (c+d x))^2 \tan (c+d x)}{3 d}+\frac {1}{6} \int \left (6 a^2 A+3 \left (2 a^2 B+b^2 B+2 a b (2 A+C)\right ) \sec (c+d x)+2 \left (3 A b^2+6 a b B+2 a^2 C+2 b^2 C\right ) \sec ^2(c+d x)\right ) \, dx\\ &=a^2 A x+\frac {b (3 b B+2 a C) \sec (c+d x) \tan (c+d x)}{6 d}+\frac {C (a+b \sec (c+d x))^2 \tan (c+d x)}{3 d}+\frac {1}{3} \left (3 A b^2+6 a b B+2 a^2 C+2 b^2 C\right ) \int \sec ^2(c+d x) \, dx+\frac {1}{2} \left (2 a^2 B+b^2 B+2 a b (2 A+C)\right ) \int \sec (c+d x) \, dx\\ &=a^2 A x+\frac {\left (2 a^2 B+b^2 B+2 a b (2 A+C)\right ) \tanh ^{-1}(\sin (c+d x))}{2 d}+\frac {b (3 b B+2 a C) \sec (c+d x) \tan (c+d x)}{6 d}+\frac {C (a+b \sec (c+d x))^2 \tan (c+d x)}{3 d}-\frac {\left (3 A b^2+6 a b B+2 a^2 C+2 b^2 C\right ) \text {Subst}(\int 1 \, dx,x,-\tan (c+d x))}{3 d}\\ &=a^2 A x+\frac {\left (2 a^2 B+b^2 B+2 a b (2 A+C)\right ) \tanh ^{-1}(\sin (c+d x))}{2 d}+\frac {\left (3 A b^2+6 a b B+2 a^2 C+2 b^2 C\right ) \tan (c+d x)}{3 d}+\frac {b (3 b B+2 a C) \sec (c+d x) \tan (c+d x)}{6 d}+\frac {C (a+b \sec (c+d x))^2 \tan (c+d x)}{3 d}\\ \end {align*}

________________________________________________________________________________________

Mathematica [B] Leaf count is larger than twice the leaf count of optimal. \(322\) vs. \(2(134)=268\).
time = 1.77, size = 322, normalized size = 2.40 \begin {gather*} \frac {\sec ^3(c+d x) \left (9 \cos (c+d x) \left (2 a^2 A (c+d x)-\left (2 a^2 B+b^2 B+2 a b (2 A+C)\right ) \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )+\left (2 a^2 B+b^2 B+2 a b (2 A+C)\right ) \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )\right )+3 \cos (3 (c+d x)) \left (2 a^2 A (c+d x)-\left (2 a^2 B+b^2 B+2 a b (2 A+C)\right ) \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right )+\left (2 a^2 B+b^2 B+2 a b (2 A+C)\right ) \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right )\right )+4 \left (3 A b^2+6 a b B+3 a^2 C+4 b^2 C+3 b (b B+2 a C) \cos (c+d x)+\left (3 A b^2+6 a b B+3 a^2 C+2 b^2 C\right ) \cos (2 (c+d x))\right ) \sin (c+d x)\right )}{24 d} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[(a + b*Sec[c + d*x])^2*(A + B*Sec[c + d*x] + C*Sec[c + d*x]^2),x]

[Out]

(Sec[c + d*x]^3*(9*Cos[c + d*x]*(2*a^2*A*(c + d*x) - (2*a^2*B + b^2*B + 2*a*b*(2*A + C))*Log[Cos[(c + d*x)/2]
- Sin[(c + d*x)/2]] + (2*a^2*B + b^2*B + 2*a*b*(2*A + C))*Log[Cos[(c + d*x)/2] + Sin[(c + d*x)/2]]) + 3*Cos[3*
(c + d*x)]*(2*a^2*A*(c + d*x) - (2*a^2*B + b^2*B + 2*a*b*(2*A + C))*Log[Cos[(c + d*x)/2] - Sin[(c + d*x)/2]] +
 (2*a^2*B + b^2*B + 2*a*b*(2*A + C))*Log[Cos[(c + d*x)/2] + Sin[(c + d*x)/2]]) + 4*(3*A*b^2 + 6*a*b*B + 3*a^2*
C + 4*b^2*C + 3*b*(b*B + 2*a*C)*Cos[c + d*x] + (3*A*b^2 + 6*a*b*B + 3*a^2*C + 2*b^2*C)*Cos[2*(c + d*x)])*Sin[c
 + d*x]))/(24*d)

________________________________________________________________________________________

Maple [A]
time = 0.08, size = 183, normalized size = 1.37

method result size
derivativedivides \(\frac {A \,b^{2} \tan \left (d x +c \right )+b^{2} B \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )-b^{2} C \left (-\frac {2}{3}-\frac {\left (\sec ^{2}\left (d x +c \right )\right )}{3}\right ) \tan \left (d x +c \right )+2 a A b \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+2 a b B \tan \left (d x +c \right )+2 a b C \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )+A \,a^{2} \left (d x +c \right )+a^{2} B \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+a^{2} C \tan \left (d x +c \right )}{d}\) \(183\)
default \(\frac {A \,b^{2} \tan \left (d x +c \right )+b^{2} B \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )-b^{2} C \left (-\frac {2}{3}-\frac {\left (\sec ^{2}\left (d x +c \right )\right )}{3}\right ) \tan \left (d x +c \right )+2 a A b \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+2 a b B \tan \left (d x +c \right )+2 a b C \left (\frac {\sec \left (d x +c \right ) \tan \left (d x +c \right )}{2}+\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )+A \,a^{2} \left (d x +c \right )+a^{2} B \ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )+a^{2} C \tan \left (d x +c \right )}{d}\) \(183\)
norman \(\frac {a^{2} A x \left (\tan ^{6}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )-a^{2} A x +\frac {4 \left (3 A \,b^{2}+6 a b B +3 a^{2} C +b^{2} C \right ) \left (\tan ^{3}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{3 d}-\frac {\left (2 A \,b^{2}+4 a b B -b^{2} B +2 a^{2} C -2 a b C +2 b^{2} C \right ) \left (\tan ^{5}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d}-\frac {\left (2 A \,b^{2}+4 a b B +b^{2} B +2 a^{2} C +2 a b C +2 b^{2} C \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{d}+3 a^{2} A x \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )-3 a^{2} A x \left (\tan ^{4}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{\left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )^{3}}-\frac {\left (4 a A b +2 a^{2} B +b^{2} B +2 a b C \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{2 d}+\frac {\left (4 a A b +2 a^{2} B +b^{2} B +2 a b C \right ) \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{2 d}\) \(295\)
risch \(a^{2} A x -\frac {i \left (3 B \,b^{2} {\mathrm e}^{5 i \left (d x +c \right )}+6 C a b \,{\mathrm e}^{5 i \left (d x +c \right )}-6 A \,b^{2} {\mathrm e}^{4 i \left (d x +c \right )}-12 B a b \,{\mathrm e}^{4 i \left (d x +c \right )}-6 C \,a^{2} {\mathrm e}^{4 i \left (d x +c \right )}-12 A \,b^{2} {\mathrm e}^{2 i \left (d x +c \right )}-24 B a b \,{\mathrm e}^{2 i \left (d x +c \right )}-12 C \,a^{2} {\mathrm e}^{2 i \left (d x +c \right )}-12 C \,b^{2} {\mathrm e}^{2 i \left (d x +c \right )}-3 B \,b^{2} {\mathrm e}^{i \left (d x +c \right )}-6 C b a \,{\mathrm e}^{i \left (d x +c \right )}-6 A \,b^{2}-12 a b B -6 a^{2} C -4 b^{2} C \right )}{3 d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{3}}+\frac {2 b a \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) A}{d}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) a^{2} B}{d}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) b^{2} B}{2 d}+\frac {b a \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) C}{d}-\frac {2 b a \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) A}{d}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) a^{2} B}{d}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) b^{2} B}{2 d}-\frac {b a \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) C}{d}\) \(382\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a+b*sec(d*x+c))^2*(A+B*sec(d*x+c)+C*sec(d*x+c)^2),x,method=_RETURNVERBOSE)

[Out]

1/d*(A*b^2*tan(d*x+c)+b^2*B*(1/2*sec(d*x+c)*tan(d*x+c)+1/2*ln(sec(d*x+c)+tan(d*x+c)))-b^2*C*(-2/3-1/3*sec(d*x+
c)^2)*tan(d*x+c)+2*a*A*b*ln(sec(d*x+c)+tan(d*x+c))+2*a*b*B*tan(d*x+c)+2*a*b*C*(1/2*sec(d*x+c)*tan(d*x+c)+1/2*l
n(sec(d*x+c)+tan(d*x+c)))+A*a^2*(d*x+c)+a^2*B*ln(sec(d*x+c)+tan(d*x+c))+a^2*C*tan(d*x+c))

________________________________________________________________________________________

Maxima [A]
time = 0.31, size = 207, normalized size = 1.54 \begin {gather*} \frac {12 \, {\left (d x + c\right )} A a^{2} + 4 \, {\left (\tan \left (d x + c\right )^{3} + 3 \, \tan \left (d x + c\right )\right )} C b^{2} - 6 \, C a b {\left (\frac {2 \, \sin \left (d x + c\right )}{\sin \left (d x + c\right )^{2} - 1} - \log \left (\sin \left (d x + c\right ) + 1\right ) + \log \left (\sin \left (d x + c\right ) - 1\right )\right )} - 3 \, B b^{2} {\left (\frac {2 \, \sin \left (d x + c\right )}{\sin \left (d x + c\right )^{2} - 1} - \log \left (\sin \left (d x + c\right ) + 1\right ) + \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + 12 \, B a^{2} \log \left (\sec \left (d x + c\right ) + \tan \left (d x + c\right )\right ) + 24 \, A a b \log \left (\sec \left (d x + c\right ) + \tan \left (d x + c\right )\right ) + 12 \, C a^{2} \tan \left (d x + c\right ) + 24 \, B a b \tan \left (d x + c\right ) + 12 \, A b^{2} \tan \left (d x + c\right )}{12 \, d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*sec(d*x+c))^2*(A+B*sec(d*x+c)+C*sec(d*x+c)^2),x, algorithm="maxima")

[Out]

1/12*(12*(d*x + c)*A*a^2 + 4*(tan(d*x + c)^3 + 3*tan(d*x + c))*C*b^2 - 6*C*a*b*(2*sin(d*x + c)/(sin(d*x + c)^2
 - 1) - log(sin(d*x + c) + 1) + log(sin(d*x + c) - 1)) - 3*B*b^2*(2*sin(d*x + c)/(sin(d*x + c)^2 - 1) - log(si
n(d*x + c) + 1) + log(sin(d*x + c) - 1)) + 12*B*a^2*log(sec(d*x + c) + tan(d*x + c)) + 24*A*a*b*log(sec(d*x +
c) + tan(d*x + c)) + 12*C*a^2*tan(d*x + c) + 24*B*a*b*tan(d*x + c) + 12*A*b^2*tan(d*x + c))/d

________________________________________________________________________________________

Fricas [A]
time = 3.53, size = 179, normalized size = 1.34 \begin {gather*} \frac {12 \, A a^{2} d x \cos \left (d x + c\right )^{3} + 3 \, {\left (2 \, B a^{2} + 2 \, {\left (2 \, A + C\right )} a b + B b^{2}\right )} \cos \left (d x + c\right )^{3} \log \left (\sin \left (d x + c\right ) + 1\right ) - 3 \, {\left (2 \, B a^{2} + 2 \, {\left (2 \, A + C\right )} a b + B b^{2}\right )} \cos \left (d x + c\right )^{3} \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, {\left (2 \, C b^{2} + 2 \, {\left (3 \, C a^{2} + 6 \, B a b + {\left (3 \, A + 2 \, C\right )} b^{2}\right )} \cos \left (d x + c\right )^{2} + 3 \, {\left (2 \, C a b + B b^{2}\right )} \cos \left (d x + c\right )\right )} \sin \left (d x + c\right )}{12 \, d \cos \left (d x + c\right )^{3}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*sec(d*x+c))^2*(A+B*sec(d*x+c)+C*sec(d*x+c)^2),x, algorithm="fricas")

[Out]

1/12*(12*A*a^2*d*x*cos(d*x + c)^3 + 3*(2*B*a^2 + 2*(2*A + C)*a*b + B*b^2)*cos(d*x + c)^3*log(sin(d*x + c) + 1)
 - 3*(2*B*a^2 + 2*(2*A + C)*a*b + B*b^2)*cos(d*x + c)^3*log(-sin(d*x + c) + 1) + 2*(2*C*b^2 + 2*(3*C*a^2 + 6*B
*a*b + (3*A + 2*C)*b^2)*cos(d*x + c)^2 + 3*(2*C*a*b + B*b^2)*cos(d*x + c))*sin(d*x + c))/(d*cos(d*x + c)^3)

________________________________________________________________________________________

Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \left (a + b \sec {\left (c + d x \right )}\right )^{2} \left (A + B \sec {\left (c + d x \right )} + C \sec ^{2}{\left (c + d x \right )}\right )\, dx \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*sec(d*x+c))**2*(A+B*sec(d*x+c)+C*sec(d*x+c)**2),x)

[Out]

Integral((a + b*sec(c + d*x))**2*(A + B*sec(c + d*x) + C*sec(c + d*x)**2), x)

________________________________________________________________________________________

Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 364 vs. \(2 (126) = 252\).
time = 0.52, size = 364, normalized size = 2.72 \begin {gather*} \frac {6 \, {\left (d x + c\right )} A a^{2} + 3 \, {\left (2 \, B a^{2} + 4 \, A a b + 2 \, C a b + B b^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right ) - 3 \, {\left (2 \, B a^{2} + 4 \, A a b + 2 \, C a b + B b^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right ) - \frac {2 \, {\left (6 \, C a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 12 \, B a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 6 \, C a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 6 \, A b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 3 \, B b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} + 6 \, C b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{5} - 12 \, C a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 24 \, B a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 12 \, A b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 4 \, C b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 6 \, C a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 12 \, B a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 6 \, C a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 6 \, A b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 3 \, B b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 6 \, C b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )}}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1\right )}^{3}}}{6 \, d} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*sec(d*x+c))^2*(A+B*sec(d*x+c)+C*sec(d*x+c)^2),x, algorithm="giac")

[Out]

1/6*(6*(d*x + c)*A*a^2 + 3*(2*B*a^2 + 4*A*a*b + 2*C*a*b + B*b^2)*log(abs(tan(1/2*d*x + 1/2*c) + 1)) - 3*(2*B*a
^2 + 4*A*a*b + 2*C*a*b + B*b^2)*log(abs(tan(1/2*d*x + 1/2*c) - 1)) - 2*(6*C*a^2*tan(1/2*d*x + 1/2*c)^5 + 12*B*
a*b*tan(1/2*d*x + 1/2*c)^5 - 6*C*a*b*tan(1/2*d*x + 1/2*c)^5 + 6*A*b^2*tan(1/2*d*x + 1/2*c)^5 - 3*B*b^2*tan(1/2
*d*x + 1/2*c)^5 + 6*C*b^2*tan(1/2*d*x + 1/2*c)^5 - 12*C*a^2*tan(1/2*d*x + 1/2*c)^3 - 24*B*a*b*tan(1/2*d*x + 1/
2*c)^3 - 12*A*b^2*tan(1/2*d*x + 1/2*c)^3 - 4*C*b^2*tan(1/2*d*x + 1/2*c)^3 + 6*C*a^2*tan(1/2*d*x + 1/2*c) + 12*
B*a*b*tan(1/2*d*x + 1/2*c) + 6*C*a*b*tan(1/2*d*x + 1/2*c) + 6*A*b^2*tan(1/2*d*x + 1/2*c) + 3*B*b^2*tan(1/2*d*x
 + 1/2*c) + 6*C*b^2*tan(1/2*d*x + 1/2*c))/(tan(1/2*d*x + 1/2*c)^2 - 1)^3)/d

________________________________________________________________________________________

Mupad [B]
time = 5.91, size = 512, normalized size = 3.82 \begin {gather*} \frac {\frac {A\,b^2\,\sin \left (3\,c+3\,d\,x\right )}{4}+\frac {B\,b^2\,\sin \left (2\,c+2\,d\,x\right )}{4}+\frac {C\,a^2\,\sin \left (3\,c+3\,d\,x\right )}{4}+\frac {C\,b^2\,\sin \left (3\,c+3\,d\,x\right )}{6}+\frac {A\,b^2\,\sin \left (c+d\,x\right )}{4}+\frac {C\,a^2\,\sin \left (c+d\,x\right )}{4}+\frac {C\,b^2\,\sin \left (c+d\,x\right )}{2}+\frac {B\,a\,b\,\sin \left (3\,c+3\,d\,x\right )}{2}+\frac {C\,a\,b\,\sin \left (2\,c+2\,d\,x\right )}{2}+\frac {3\,A\,a^2\,\cos \left (c+d\,x\right )\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{2}+\frac {3\,B\,a^2\,\cos \left (c+d\,x\right )\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{2}+\frac {3\,B\,b^2\,\cos \left (c+d\,x\right )\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{4}+\frac {A\,a^2\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\cos \left (3\,c+3\,d\,x\right )}{2}+\frac {B\,a^2\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\cos \left (3\,c+3\,d\,x\right )}{2}+\frac {B\,b^2\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\cos \left (3\,c+3\,d\,x\right )}{4}+\frac {B\,a\,b\,\sin \left (c+d\,x\right )}{2}+3\,A\,a\,b\,\cos \left (c+d\,x\right )\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )+\frac {3\,C\,a\,b\,\cos \left (c+d\,x\right )\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{2}+A\,a\,b\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\cos \left (3\,c+3\,d\,x\right )+\frac {C\,a\,b\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )\,\cos \left (3\,c+3\,d\,x\right )}{2}}{d\,\left (\frac {3\,\cos \left (c+d\,x\right )}{4}+\frac {\cos \left (3\,c+3\,d\,x\right )}{4}\right )} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a + b/cos(c + d*x))^2*(A + B/cos(c + d*x) + C/cos(c + d*x)^2),x)

[Out]

((A*b^2*sin(3*c + 3*d*x))/4 + (B*b^2*sin(2*c + 2*d*x))/4 + (C*a^2*sin(3*c + 3*d*x))/4 + (C*b^2*sin(3*c + 3*d*x
))/6 + (A*b^2*sin(c + d*x))/4 + (C*a^2*sin(c + d*x))/4 + (C*b^2*sin(c + d*x))/2 + (B*a*b*sin(3*c + 3*d*x))/2 +
 (C*a*b*sin(2*c + 2*d*x))/2 + (3*A*a^2*cos(c + d*x)*atan(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)))/2 + (3*B*a^2*
cos(c + d*x)*atanh(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)))/2 + (3*B*b^2*cos(c + d*x)*atanh(sin(c/2 + (d*x)/2)/
cos(c/2 + (d*x)/2)))/4 + (A*a^2*atan(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2))*cos(3*c + 3*d*x))/2 + (B*a^2*atanh
(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2))*cos(3*c + 3*d*x))/2 + (B*b^2*atanh(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/
2))*cos(3*c + 3*d*x))/4 + (B*a*b*sin(c + d*x))/2 + 3*A*a*b*cos(c + d*x)*atanh(sin(c/2 + (d*x)/2)/cos(c/2 + (d*
x)/2)) + (3*C*a*b*cos(c + d*x)*atanh(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2)))/2 + A*a*b*atanh(sin(c/2 + (d*x)/2
)/cos(c/2 + (d*x)/2))*cos(3*c + 3*d*x) + (C*a*b*atanh(sin(c/2 + (d*x)/2)/cos(c/2 + (d*x)/2))*cos(3*c + 3*d*x))
/2)/(d*((3*cos(c + d*x))/4 + cos(3*c + 3*d*x)/4))

________________________________________________________________________________________